using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc.Binders;

namespace HengTong.Model.Db.Article;

/// <summary>
/// 文章实体类
/// </summary>
public class SysArticle : BasePoco
{
    // 基本信息
    [Required]
    [Display(Name = "文章标题", Description = "文章标题", GroupName = "基本信息")]
    [StringLength(256)]
    public string Title { get; set; }

    [Display(Name = "副标题", Description = "文章副标题", GroupName = "基本信息")]
    [StringLength(256)]
    public string SubTitle { get; set; }

    [Display(Name = "文章摘要", Description = "文章摘要或简介", GroupName = "基本信息")]
    [StringLength(1000)]
    public string Summary { get; set; }

    [Required]
    [JsonConverter(typeof(JsonStringConverter))]
    [Display(Name = "文章内容", Description = "文章正文内容", GroupName = "内容信息")]
    public string Content { get; set; }

    [Display(Name = "文章状态", Description = "文章状态", GroupName = "状态信息")]
    public ArticleStatus? Status { get; set; } = ArticleStatus.草稿;

    // 分类关联
    [Display(Name = "文章分类ID", Description = "关联的文章分类ID", GroupName = "分类信息")]
    public Guid? CategoryId { get; set; }

    [Display(Name = "文章分类", Description = "关联的文章分类", GroupName = "分类信息")]
    public SysArticleCategory Category { get; set; }

    // 显示设置
    [Display(Name = "排序", Description = "文章显示排序，数值越小越靠前", GroupName = "显示设置")]
    public int? SortOrder { get; set; }

    [Display(Name = "是否置顶", Description = "是否置顶显示", GroupName = "显示设置")]
    public bool IsTop { get; set; } = false;

    [Display(Name = "是否推荐", Description = "是否推荐文章", GroupName = "显示设置")]
    public bool IsRecommend { get; set; } = false;

    [Display(Name = "封面图片ID", Description = "文章封面图片ID", GroupName = "显示设置")]
    public Guid? CoverImageId { get; set; }

    [Display(Name = "封面图片", Description = "文章封面图片", GroupName = "显示设置")]
    public FileAttachment CoverImage { get; set; }

    // 统计信息
    [Display(Name = "阅读次数", Description = "文章阅读次数", GroupName = "统计信息")]
    public int ViewCount { get; set; } = 0;

    [Display(Name = "点赞次数", Description = "文章点赞次数", GroupName = "统计信息")]
    public int LikeCount { get; set; } = 0;

    [Display(Name = "评论次数", Description = "文章评论次数", GroupName = "统计信息")]
    public int CommentCount { get; set; } = 0;

    [Display(Name = "收藏次数", Description = "文章收藏次数", GroupName = "统计信息")]
    public int FavoriteCount { get; set; } = 0;

    [Display(Name = "分享次数", Description = "文章分享次数", GroupName = "统计信息")]
    public int ShareCount { get; set; } = 0;

    // 导航属性
    [Display(Name = "文章标签关联")]
    public virtual ICollection<SysArticleTagMapping> ArticleTagMappings { get; set; }

    [Display(Name = "文章附件")]
    public virtual ICollection<SysArticleAttachment> ArticleAttachments { get; set; }
}